package PTA.javabianchengjichu2;

import java.util.ArrayList;
import java.util.Scanner;

public class ex07 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ArrayList<String> strList = new ArrayList<>();
        while(true){
            String line = sc.next();
            if(line.equals("!!end!!")){
                break;
            }
            strList.add(line);//添加元素
        }
strList.add(0,"begin");
        strList.add("end");
        System.out.println(strList);//输出列表元素
        String str = sc.next();//输入字符串str
        System.out.println(strList.contains(str));
        System.out.println(strList.indexOf(str));
        System.out.println(strList.lastIndexOf(str));
        System.out.println(strList.get(0));
        strList.remove(0);
        System.out.println(strList);
        String str2 = sc.next();
        strList.set(1,str2);
        System.out.println(strList);
        ArrayList<String> list1 = new ArrayList<>();
        String str3 = sc.next();
        sc.close();
        for(String s:strList){
            if(s.contains(str3)){
                list1.add(s);
            }
        }
        System.out.println(list1);
        strList.remove(str3);
        System.out.println(strList);
        strList.clear();
        System.out.println(strList+","+strList.size()+","+strList.isEmpty());

    }
}
